// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/sync/test/integration/two_client_web_apps_integration_test_base.h"
#include "content/public/test/browser_test.h"

namespace web_app {

// This test is a part of the web app integration test suite, which is
// documented in //chrome/browser/ui/views/web_apps/README.md. For information
// about diagnosing, debugging and/or disabling tests, please look to the
// README file.

namespace {

using TwoClientWebAppsIntegrationTestCros = TwoClientWebAppsIntegrationTestBase;

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctTabbedSiteA_InListTabbedSiteA_SwitchProfileClientClient2_InListTabbedSiteA_LaunchFromListSiteA_TabCreated) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutTabbed("SiteA");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.LaunchFromChromeApps("SiteA");
  helper_.CheckTabCreated();
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctWindowedSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_NavSiteA_InstIconNotShown_LaunchIconShown) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutWindowed("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.NavigateBrowser("SiteA");
  helper_.CheckInstallIconNotShown();
  helper_.CheckLaunchIconShown();
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstOmniboxSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_NavSiteA_InstIconNotShown_LaunchIconShown) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallOmniboxIcon("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.NavigateBrowser("SiteA");
  helper_.CheckInstallIconNotShown();
  helper_.CheckLaunchIconShown();
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstMenuOptionSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_NavSiteA_InstIconNotShown_LaunchIconShown) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallMenuOption("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.NavigateBrowser("SiteA");
  helper_.CheckInstallIconNotShown();
  helper_.CheckLaunchIconShown();
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctWindowedSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_UninstallFromListSiteA_NotInListSiteA_SwitchProfileClientClient1_NotInListSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutWindowed("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.UninstallFromList("SiteA");
  helper_.CheckAppNotInList("SiteA");
  helper_.SwitchProfileClients("Client1");
  helper_.CheckAppNotInList("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstOmniboxSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_UninstallFromListSiteA_NotInListSiteA_SwitchProfileClientClient1_NotInListSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallOmniboxIcon("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.UninstallFromList("SiteA");
  helper_.CheckAppNotInList("SiteA");
  helper_.SwitchProfileClients("Client1");
  helper_.CheckAppNotInList("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstMenuOptionSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_UninstallFromListSiteA_NotInListSiteA_SwitchProfileClientClient1_NotInListSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallMenuOption("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.UninstallFromList("SiteA");
  helper_.CheckAppNotInList("SiteA");
  helper_.SwitchProfileClients("Client1");
  helper_.CheckAppNotInList("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctTabbedSiteA_InListTabbedSiteA_SwitchProfileClientClient2_InListTabbedSiteA_UninstallFromListSiteA_NotInListSiteA_SwitchProfileClientClient1_NotInListSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutTabbed("SiteA");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.UninstallFromList("SiteA");
  helper_.CheckAppNotInList("SiteA");
  helper_.SwitchProfileClients("Client1");
  helper_.CheckAppNotInList("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctWindowedSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_TurnSyncOff_UninstallFromListSiteA_TurnSyncOn_InListWinSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutWindowed("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SyncTurnOff();
  helper_.UninstallFromList("SiteA");
  helper_.SyncTurnOn();
  helper_.CheckAppInListWindowed("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstOmniboxSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_TurnSyncOff_UninstallFromListSiteA_TurnSyncOn_InListWinSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallOmniboxIcon("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SyncTurnOff();
  helper_.UninstallFromList("SiteA");
  helper_.SyncTurnOn();
  helper_.CheckAppInListWindowed("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstMenuOptionSiteA_WindowCreated_InListWinSiteA_SwitchProfileClientClient2_InListWinSiteA_TurnSyncOff_UninstallFromListSiteA_TurnSyncOn_InListWinSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallMenuOption("SiteA");
  helper_.CheckWindowCreated();
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListWindowed("SiteA");
  helper_.SyncTurnOff();
  helper_.UninstallFromList("SiteA");
  helper_.SyncTurnOn();
  helper_.CheckAppInListWindowed("SiteA");
}

IN_PROC_BROWSER_TEST_F(
    TwoClientWebAppsIntegrationTestCros,
    WebAppIntegration_InstCrtShctTabbedSiteA_InListTabbedSiteA_SwitchProfileClientClient2_InListTabbedSiteA_TurnSyncOff_UninstallFromListSiteA_TurnSyncOn_InListTabbedSiteA) {
  // Test contents are generated by script. Please do not modify!
  // See `chrome/test/webapps/README.md` for more info.
  // Sheriffs: Disabling this test is supported.
  helper_.InstallCreateShortcutTabbed("SiteA");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.SwitchProfileClients("Client2");
  helper_.CheckAppInListTabbed("SiteA");
  helper_.SyncTurnOff();
  helper_.UninstallFromList("SiteA");
  helper_.SyncTurnOn();
  helper_.CheckAppInListTabbed("SiteA");
}

}  // namespace
}  // namespace web_app
